package com.hxk;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

import com.hxk.servlet.MyServlet2;

/**
 * springboot整合servlet方式二
 * 通过方法配置方法
 * @author Cactus
 *
 */
@SpringBootApplication
public class App2 {

	public static void main(String[] args) {
		SpringApplication.run(App2.class, args);
	}
	/**
	 * 注册servlet
	 * @return
	 */
	@Bean
	public ServletRegistrationBean getServletRegistrationBean() {
		ServletRegistrationBean bean = new ServletRegistrationBean(new MyServlet2());
		bean.addUrlMappings("/demo2");
		return bean;
	}

}
